<div>
    <h2>
        <span jhiTranslate="greatBigExampleApplicationApp.comment.home.title">Comments</span>
        <button class="btn btn-primary float-right create-comment" [routerLink]="['/', { outlets: { popup: ['comment-new'] } }]">
            <span class="fa fa-plus"></span>
            <span class="hidden-sm-down"  jhiTranslate="greatBigExampleApplicationApp.comment.home.createLabel">
            Create new Comment
            </span>
        </button>
    </h2>
    <jhi-alert></jhi-alert>
    <div class="row">
        <div class="col-sm-12">
            <form name="searchForm" class="form-inline">
                <div class="input-group w-100 mt-3">
                    <input type="text" class="form-control" [(ngModel)]="currentSearch" id="currentSearch" name="currentSearch" placeholder="{{ 'greatBigExampleApplicationApp.comment.home.search' | translate }}">
                    <button class="input-group-addon btn btn-info" (click)="search(currentSearch)">
                        <span class="fa fa-search"></span>
                    </button>
                    <button class="input-group-addon btn btn-danger" (click)="clear()" *ngIf="currentSearch">
                        <span class="fa fa-trash-o"></span>
                    </button>
                </div>
            </form>
        </div>
    </div>
    <br/>
    <div class="table-responsive" *ngIf="comments">
        <table class="table table-striped">
            <thead>
            <tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="transition.bind(this)">
            <th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="body"><span jhiTranslate="greatBigExampleApplicationApp.comment.body">Body</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="createdAt"><span jhiTranslate="greatBigExampleApplicationApp.comment.createdAt">Created At</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="updatedAt"><span jhiTranslate="greatBigExampleApplicationApp.comment.updatedAt">Updated At</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="article.id"><span jhiTranslate="greatBigExampleApplicationApp.comment.article">Article</span> <span class="fa fa-sort"></span></th>
            <th jhiSortBy="author.id"><span jhiTranslate="greatBigExampleApplicationApp.comment.author">Author</span> <span class="fa fa-sort"></span></th>
            <th></th>
            </tr>
            </thead>
            <tbody>
            <tr *ngFor="let comment of comments ;trackBy: trackId">
                <td><a [routerLink]="['../comment', comment.id ]">{{comment.id}}</a></td>
                <td>{{comment.body}}</td>
                <td>{{comment.createdAt | date:'medium'}}</td>
                <td>{{comment.updatedAt | date:'medium'}}</td>
                <td>
                    <div *ngIf="comment.article">
                        <a [routerLink]="['../article', comment.article?.id ]" >{{comment.article?.id}}</a>
                    </div>
                </td>
                <td>
                    <div *ngIf="comment.author">
                        <a [routerLink]="['../author', comment.author?.id ]" >{{comment.author?.id}}</a>
                    </div>
                </td>
                <td class="text-right">
                    <div class="btn-group flex-btn-group-container">
                        <button type="submit"
                                [routerLink]="['../comment', comment.id ]"
                                class="btn btn-info btn-sm">
                            <span class="fa fa-eye"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.view">View</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'comment/'+ comment.id + '/edit'} }]"
                                replaceUrl="true"
                                class="btn btn-primary btn-sm">
                            <span class="fa fa-pencil"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.edit">Edit</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'comment/'+ comment.id + '/delete'} }]"
                                replaceUrl="true"
                                class="btn btn-danger btn-sm">
                            <span class="fa fa-remove"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.delete">Delete</span>
                        </button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
        <!-- Pager is not implemented yet, so this is normal pagination instead -->
        <div *ngIf="comments && comments.length">
            <div class="row justify-content-center">
                <jhi-item-count [page]="page" [total]="queryCount" [itemsPerPage]="itemsPerPage"></jhi-item-count>
            </div>
            <div class="row justify-content-center">
                <ngb-pagination [collectionSize]="totalItems" [(page)]="page"  (pageChange)="loadPage(page)"></ngb-pagination>
            </div>
        </div>
</div>
